Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace http-proxy server with BrowserSync proxy (docker development) #150

Merged
merged 38 commits into from
Jan 11, 2023

Conversation

Raruto
Copy link
Collaborator

@Raruto Raruto commented Aug 22, 2022

BrowserSync already comes with a proxy server, so:

  • make use of built in browser-sync proxy server within gulpfile.js
  • remove useless deprecate variable G3W_PROXY_ROUTES within config.template.js
  • remove gulp task plugins
  • refactor gulp task g3w-admin:plugins
  • refactor gulp task select-plugins

Refactor and simply vendors build chain:

  • remove src/assets/vendors/index.css.html
  • remove src/assets/vendors/index.js.html
  • remove src/index.dev.html
  • rename src/index.prod.html into src/index.html
  • deprecate config.template.js variables (distFolder, clientFolder, admin_static_folder, admin_templates_folder)
  • add new variable within config.template.js (admin_overrides_folder) and
  • add new variable within gulpfile.js (outputFolder) in order to properly handle dev and build tasks

Handle local developed plugins:

  • add new variable within config.template.js (devConfig)
  • deprecate variable within config.template.js (createProject)
  • deprecate variable within config.template.js (setCurrentProject)
  • automatically toggle class="skin-blue" on body tag (dev environment)
  • refactor function ApplicationService::obtainInitConfig() and
  • move require('app/dev') into src/app/main.js (application entry point)
  • remove mandatory gid and baseurl options within G3W_PLUGINS
    • convert variable G3W_PLUGINS into array (list of locally developed plugins) (ref. config.template.js)
    • automatically assing gid and baseurl parameter for all locally developed plugins (ref: src/app/dev/index.js)

More info:

How to test:

Update your config.js file as per 516f734:

 admin_plugins_folder:   '../g3w-admin/g3w-admin',                         // path to G3W-ADMIN where are stored all plugin folders 
 admin_overrides_folder: '../g3w-suite-docker/config/g3w-suite/overrides', // path to G3W-SUITE overrides folder 

Add the following lines at the top of your g3w-suite-docker/config/g3w-suite/settings_docker.py file

#
# see: https://github.com/g3w-suite/g3w-suite-docker/pull/62
#
settings.TEMPLATES[0]['DIRS'].append(os.path.join(settings.BASE_DIR, '../../templates')) # /code/templates
settings.STATICFILES_DIRS.append(os.path.join(settings.BASE_DIR, '../../static'))        # /code/static

Run (and test) the following scripts:

npm run dev
npm run build
npm run build:plugins

Check that the following rules apply while developing:

# EXAMPLE 1:
# project_group = "countries";
# project_type  = "qdjango";
# project_id    = "1"

http://localhost:8000/en/map/countries/qdjango/1 # g3w-admin  (production)
http://localhost:3000/en/map/countries/qdjango/1 # g3w-client (development)
g3w-suite-docker/config/g3w-suite/overrides/static    # output path for static files (css, js, fonts, ...)
g3w-suite-docker/config/g3w-suite/overrides/templates # output path for templates files (index.html)

Related to #137 and g3w-suite/g3w-suite-docker#62

Close #48 Close #63 Close #75

Partially address: #89

- make use of built in `browser-sync` proxy server within `gulpfile.js`
- remove `G3W_PROXY_ROUTES` within `config.template.js`
@Raruto Raruto added this to the v3.7 milestone Aug 22, 2022
@Raruto Raruto added the refactoring Anything which could result in a API change label Aug 22, 2022
@Raruto
Copy link
Collaborator Author

Raruto commented Aug 22, 2022

@volterra79 before merging this let me know if I can also remove it as it project dependency within the package.json

"http-proxy": "^1.11.0",

@Raruto Raruto added docs Improvements or additions to documentation config Anything related to configuration files labels Aug 22, 2022
Copy link
Collaborator Author

@Raruto Raruto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated comment

Raruto added 8 commits August 24, 2022 09:21
- remove `src/assets/vendors/index.css.html`
- remove `src/assets/vendors/index.js.html`
- remove `src/index.dev.html`
- rename `src/index.prod.html` into `src/index.html`
- deprecate config.js variables (`distFolder`, `clientFolder`, `admin_static_folder`, `admin_templates_folder`)
- add config.js variable: `admin_overrides_folder`
- add gulpfile.js internal variable (`outputFolder`) in order to properly handle `dev` and `build` tasks
gulpfile.js Outdated Show resolved Hide resolved
Raruto added 10 commits August 31, 2022 16:03
- add parameter `devConfig` within `config.template.js`
- deprecate parameter `createProject` within `config.template.js`
- deprecate parameter `seCCurrentProject` within `config.template.js`
- automatically toggle `skin-blue` class on body tag (dev environment)
- refactor function `ApplicationService::obtainInitConfig()`
- move `require('app/dev')` into `src/app/main.js` (application entry point)
- convert variable `G3W_PLUGINS` into array (list of locally developed plugins)
- automatically assing `gid` and `baseurl` parameter for all locally developed plugins (ref: `src/app/dev/index.js`)
- add `gulp-sourcemaps` on production environment
make use of `transform` option instead of chaining transform methods
src/services/application.js Show resolved Hide resolved
src/app/main.js Show resolved Hide resolved
@Raruto Raruto changed the title Remove http-proxy server from gulpfile.js Replace http-proxy server with BrowserSync proxy (dockerized developoment) Sep 14, 2022
@Raruto Raruto modified the milestones: v3.8, v3.7 Oct 28, 2022
@Raruto
Copy link
Collaborator Author

Raruto commented Oct 31, 2022

@volterra79 for me we are ready to merge this, so we can finally release v3.7.0-beta.0

@volterra79 volterra79 modified the milestones: v3.7, v3.8 Nov 14, 2022
config.template.js Outdated Show resolved Hide resolved
volterra79 and others added 3 commits January 10, 2023 14:36
…ed to g3w_admin folder and not to plugins"

This reverts commit 186d37f
…ed to g3w_admin folder and not to plugins"

This reverts commit 186d37f
…oup, type and id parameters to get initial configuration from g3w-admin server
@volterra79 volterra79 merged commit 9e41f4e into dev Jan 11, 2023
@volterra79 volterra79 deleted the browser-sync-proxy branch January 11, 2023 14:45
volterra79 added a commit that referenced this pull request Jan 11, 2023
…ent) (#150)

* Remove `http-proxy` server

- make use of built in `browser-sync` proxy server within `gulpfile.js`
- remove `G3W_PROXY_ROUTES` within `config.template.js`

* update development URLs within `readme.md`

* Fix wrong merge

* Proxy routes fallback within `config.template.js` (v3.x)

* remove gulp task `plugins`

* remove "glob" need when updating plugin files

* refactor and simply vendors build chain

- remove `src/assets/vendors/index.css.html`
- remove `src/assets/vendors/index.js.html`
- remove `src/index.dev.html`
- rename `src/index.prod.html` into `src/index.html`
- deprecate config.js variables (`distFolder`, `clientFolder`, `admin_static_folder`, `admin_templates_folder`)
- add config.js variable: `admin_overrides_folder`
- add gulpfile.js internal variable (`outputFolder`) in order to properly handle `dev` and `build` tasks

* reduce delta

* update comments

* live reload application on plugin.js changes

* add comments and sort tasks

* handle `build:plugins` task in local development

* handle local developed plugins

- add parameter `devConfig` within `config.template.js`
- deprecate parameter `createProject` within `config.template.js`
- deprecate parameter `seCCurrentProject` within `config.template.js`
- automatically toggle `skin-blue` class on body tag (dev environment)
- refactor function `ApplicationService::obtainInitConfig()`
- move `require('app/dev')` into `src/app/main.js` (application entry point)

* micro-optimization (single glob watch)

* remove mandatory `gid` and `baseurl` options within `G3W_PLUGINS`

- convert variable `G3W_PLUGINS` into array (list of locally developed plugins)
- automatically assing `gid` and `baseurl` parameter for all locally developed plugins (ref: `src/app/dev/index.js`)

* generate `app.min.js.map` (PRODUCTION)

- add `gulp-sourcemaps` on production environment

* refactor browserify transform option

make use of `transform` option instead of chaining transform methods

* restore previous plugin developement tips (v3.4)

* restore vendors fonts in gulp chain

* Update "g3w-admin" and "g3w-suite-docker" badge versions

* set v3.5 also on badge image..

* Add some minimal info about "Plugins" development

* Align with dev new css and js vendors

* Comment change skin color to skin-blue on development environment to has the same color in production

* Rename admin_plugins_folder to admin_folder because it referred to g3w_admin folder and not to plugins

* Revert "Rename admin_plugins_folder to admin_folder because it referred to g3w_admin folder and not to plugins"

This reverts commit 186d37f

* Revert "Rename admin_plugins_folder to admin_folder because it referred to g3w_admin folder and not to plugins"

This reverts commit 186d37f

* replace "comment" section with a TODO

* Add deprecate wrapper comment to a part of code to extract project group, type and id parameters to get initial configuration from g3w-admin server

Co-authored-by: volterra79 <[email protected]>
Raruto added a commit that referenced this pull request Feb 7, 2023
…ProjectsRegistry~createProject(projectConfig)`

Start addressing: #67

As a result of: #150 we intend to bring the development environment ever closer to the production one.

Related to: #89, #292 and g3w-suite/g3w-suite-docker#79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Anything related to configuration files docs Improvements or additions to documentation refactoring Anything which could result in a API change
Projects
None yet
2 participants